From f4c06611fdc4c8f9a77b7b8237d72388952c9eea Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Fri, 1 Mar 2002 15:41:59 +0000 Subject: [PATCH] Fix signed-unsigned error that was accidentally causing negative values to Fri Mar 1 10:31:14 2002 Owen Taylor * gtk/gtknotebook.c (gtk_notebook_reorder_child): Fix signed-unsigned error that was accidentally causing negative values to append, do it intentionally. Fix docs to say that negative values append. (Alexey A. Malyshev, #73108) --- ChangeLog | 8 ++++++++ ChangeLog.pre-2-0 | 8 ++++++++ ChangeLog.pre-2-10 | 8 ++++++++ ChangeLog.pre-2-2 | 8 ++++++++ ChangeLog.pre-2-4 | 8 ++++++++ ChangeLog.pre-2-6 | 8 ++++++++ ChangeLog.pre-2-8 | 8 ++++++++ gtk/gtknotebook.c | 13 +++++++++---- 8 files changed, 65 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 438c9ba703..9e7d3b8bdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Mar 1 10:31:14 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_reorder_child): + Fix signed-unsigned error that was accidentally causing + negative values to append, do it intentionally. Fix docs + to say that negative values append. (Alexey A. Malyshev, + #73108) + 2002-03-01 Alexey Malyshev * gtk+/gtk/gtkitemfactory.c diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 438c9ba703..9e7d3b8bdb 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,11 @@ +Fri Mar 1 10:31:14 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_reorder_child): + Fix signed-unsigned error that was accidentally causing + negative values to append, do it intentionally. Fix docs + to say that negative values append. (Alexey A. Malyshev, + #73108) + 2002-03-01 Alexey Malyshev * gtk+/gtk/gtkitemfactory.c diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 438c9ba703..9e7d3b8bdb 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +Fri Mar 1 10:31:14 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_reorder_child): + Fix signed-unsigned error that was accidentally causing + negative values to append, do it intentionally. Fix docs + to say that negative values append. (Alexey A. Malyshev, + #73108) + 2002-03-01 Alexey Malyshev * gtk+/gtk/gtkitemfactory.c diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 438c9ba703..9e7d3b8bdb 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,11 @@ +Fri Mar 1 10:31:14 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_reorder_child): + Fix signed-unsigned error that was accidentally causing + negative values to append, do it intentionally. Fix docs + to say that negative values append. (Alexey A. Malyshev, + #73108) + 2002-03-01 Alexey Malyshev * gtk+/gtk/gtkitemfactory.c diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 438c9ba703..9e7d3b8bdb 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +Fri Mar 1 10:31:14 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_reorder_child): + Fix signed-unsigned error that was accidentally causing + negative values to append, do it intentionally. Fix docs + to say that negative values append. (Alexey A. Malyshev, + #73108) + 2002-03-01 Alexey Malyshev * gtk+/gtk/gtkitemfactory.c diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 438c9ba703..9e7d3b8bdb 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +Fri Mar 1 10:31:14 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_reorder_child): + Fix signed-unsigned error that was accidentally causing + negative values to append, do it intentionally. Fix docs + to say that negative values append. (Alexey A. Malyshev, + #73108) + 2002-03-01 Alexey Malyshev * gtk+/gtk/gtkitemfactory.c diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 438c9ba703..9e7d3b8bdb 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +Fri Mar 1 10:31:14 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_reorder_child): + Fix signed-unsigned error that was accidentally causing + negative values to append, do it intentionally. Fix docs + to say that negative values append. (Alexey A. Malyshev, + #73108) + 2002-03-01 Alexey Malyshev * gtk+/gtk/gtkitemfactory.c diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index fd6d01cbc0..7596a6cd32 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -5010,10 +5010,12 @@ gtk_notebook_query_tab_label_packing (GtkNotebook *notebook, * gtk_notebook_reorder_child: * @notebook: a #GtkNotebook * @child: the child to move - * @position: the new position + * @position: the new position, or -1 to move to the end * * Reorders the page containing @child, so that it appears in position - * @position. Out of bounds @position will be clamped. + * @position. If @position is greater than or equal to the number of + * children in the list or negative, @child will be moved to the end + * of the list. **/ void gtk_notebook_reorder_child (GtkNotebook *notebook, @@ -5023,6 +5025,7 @@ gtk_notebook_reorder_child (GtkNotebook *notebook, GList *list, *new_list; GtkNotebookPage *page; gint old_pos; + gint max_pos; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); g_return_if_fail (GTK_IS_WIDGET (child)); @@ -5031,6 +5034,10 @@ gtk_notebook_reorder_child (GtkNotebook *notebook, if (!list) return; + max_pos = g_list_length (notebook->children) - 1; + if (position < 0 || position > max_pos) + position = max_pos; + old_pos = g_list_position (notebook->children, list); if (old_pos == position) @@ -5039,8 +5046,6 @@ gtk_notebook_reorder_child (GtkNotebook *notebook, page = list->data; notebook->children = g_list_delete_link (notebook->children, list); - position = CLAMP (position, 0, g_list_length (notebook->children)); - notebook->children = g_list_insert (notebook->children, page, position); new_list = g_list_nth (notebook->children, position); -- 2.30.2